package com.itheima.easy.web;

import com.itheima.easy.basic.ResponseWrap;
import com.itheima.easy.enums.PayChannelEnum;
import com.itheima.easy.face.RefundRecordFace;
import com.itheima.easy.utils.EmptyUtil;
import com.itheima.easy.utils.ResponseWrapBuild;
import com.itheima.easy.vo.RefundRecordVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName TradingFace.java
 * @Description 退款记录
 */
@RequestMapping("refund-records")
@RestController
@Api(tags = "退款controller")
public class RefundRecordController {

    @Autowired
    RefundRecordFace refundRecordFace;


    /***
     * @description 按交易状态查询退款记录
     * @param refundStatus
     * @return
     */
    @ApiOperation(value = "按交易状态查询退款记录",notes = "按交易状态查询退款记录")
    @ApiImplicitParam(paramType = "path",name = "refundStatus",value = "退款状态",required = true,dataType = "String")
    @GetMapping("{refundStatus}")
    ResponseWrap<List<RefundRecordVo>> findReFundRecordByRefundStatus(@PathVariable("refundStatus") String refundStatus) {
        List<RefundRecordVo> recordVoList = refundRecordFace.findRefundRecordByRefundStatus(refundStatus);
        if (EmptyUtil.isNullOrEmpty(recordVoList)) {
            ResponseWrapBuild.build(PayChannelEnum.SUCCEED, null);
        }
        return ResponseWrapBuild.build(PayChannelEnum.SUCCEED,recordVoList);
    }
}
